package org.ly817.my.spring.core;

import org.ly817.victorinox.myspring.ioc.bean.BeanDefinition;
import org.ly817.victorinox.myspring.ioc.bean.reader.XmlBeanDefinitionReader;
import org.ly817.victorinox.myspring.ioc.factory.AutowireCapableBeanFactory;
import org.ly817.victorinox.myspring.ioc.factory.BeanFactory;
import org.ly817.victorinox.myspring.ioc.io.ResourceLoader;

import java.util.Map;

/**
 * Created by LuoYu on 2018/4/10.
 */
public class Main3XMLReader {
    public static void main(String[] args) throws Exception {
        XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(new ResourceLoader());
        xmlBeanDefinitionReader.loadBeanDefinitions("myspring.xml");

        BeanFactory beanFactory = new AutowireCapableBeanFactory();
        for (Map.Entry<String, BeanDefinition> beanDefinitionEntry : xmlBeanDefinitionReader.getRegistry().entrySet()) {
//            beanFactory.registerBeanDefinition(beanDefinitionEntry.getKey(), beanDefinitionEntry.getValue());
        }

        TestService service = (TestService) beanFactory.getBean("testService");
        service.hello();
    }
}
